package com.heima.shengchanzhe;

public class Mycno implements Runnable {
    private int ticket = 100;
    private Object lock = new Object();

    @Override
    public void run() {

        while (true) {
           // synchronized (lock){
                if (ticket <= 0) {
                    break;
                } else {
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    ticket--;
                    System.out.println(Thread.currentThread().getName() + "在买票剩" + ticket + "张");
                }
            }
        }
    }
//}